Fix imports for symlinked relative paths#207
Open
jsdalton wants to merge 3 commits intoleafo:masterfrom
Open
Conversation
added 3 commits
March 12, 2012 21:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request provides a solution for the issue raised in #206.
The main change is to improve upon the regex pattern that is used to munge a folder structure containing relative paths prior to its being passed to
realpath().Previously, the regex used was:
The problem with this pattern is that it only matches folder names that contain word characters. It ignores the common hyphen character along with other. I replaced the pattern with the following:
The main difference is that '\w+/' is replaced by three alternative patterns. The three alternatives are (in the format (1|2|3) as follows):
[^.][^\/]*\/- This will match any phrase that does NOT start with a dot (.) and that is followed by zero or more characters (and terminated by a forward slash).\.[^.\/][^\/]*\/- This will match any phrase that starts with one dot and that is followed by one character that is neither a dot nor a slash, and then zero or more non-slash characters.\.\.[^\/]+\/)\.\.\//- This will match any phrase that starts with two dots and is followed by at least one non-slash characters.The regex here is somewhat obtuse, but in simple terms it matches any phrase between forward slashes except for "." and "..".
Notes on other minor changes in this pull request:
You may wish to rearrange this a bit or add some tests, but hopefully this is a decent start in the right direction.